<#import "/macro.ftl" as m>
<@m.page_header title='后台' />
<div id="page-content-wrapper">

    <div id="page-title">
        <h3>
            红包管理
        </h3>
        <div id="breadcrumb-right">
            <div class="float-right">
                <a href="/redpacket/add" class="btn medium primary-bg">
                    <span class="button-content">
                    <i class="glyph-icon icon-cog float-left"></i>
                    添加
                    </span>
                </a>
            </div>
        </div>
    </div>

    <div id="page-content">
        <table class="table" id="exp">
        </table>
    </div>
</div>
<script language="JavaScript">
    $(document).ready(function () {
    
    <#if msg!=null>
	$.jGrowl("${msg}", {sticky:!1,position:'bottom-right',theme:'bg-green'});
	</#if>

        function retrieveData(sSource, aoData, fnCallback) {
            aoData.push({ });
            $.ajax({
                "type": "POST",
                "contentType": "application/json",
                "url": sSource,
                "dataType": "json",
                "data": JSON.stringify(aoData), //以json格式传递
                "success": fnCallback
            });
        }


        $(function () {
            $("#exp").dataTable({
                sScrollY: 300,
                bJQueryUI: !0,
                bStateSave: true,
                sPaginationType: "full_numbers",
                aoColumns: [
                    {'sTitle': 'id', 'mDataProp': 'id', "bVisible": false},
                    {'sTitle': '名称', 'mDataProp': 'name'},
                    {'sTitle': '编码', 'mDataProp': 'code'},
                    {'sTitle': '面额', 'mDataProp': 'value'},
                    {'sTitle': '生效日期', 'mDataProp': 'effectDate'},
                    {'sTitle': '失效日期', 'mDataProp': 'invalidDate'},
                    {'sTitle': '期限', 'mDataProp': 'availableTime'},
                    {'sTitle': '使用说明', 'mDataProp': 'instruction'},
                    {'sTitle':'操作','bSortable':false,'mRender':function(data, type, full){
						var html='<div class="dropdown">';
			            html+='<a href="javascript:;" title="" class="btn medium bg-blue" data-toggle="dropdown">';
			            html+='<span class="button-content">';
			            html+='<i class="glyph-icon font-size-11 icon-cog"></i>';
			            html+='<i class="glyph-icon font-size-11 icon-chevron-down"></i>';
			            html+='</span>';
			            html+='</a>';
			            html+='<ul class="dropdown-menu float-right">';
			            html+='<li><a href="/redpacket/update/'+full.id+'" title=""><i class="glyph-icon icon-edit mrg5R"></i>修改</a></li>';
			            html+='<li class="divider"></li>';
			            html+='<li><a href="javascript:;" id="del_'+full.id+'" class="font-red del" title=""><i class="glyph-icon icon-remove mrg5R"></i>删除</a> </li>';
			            html+='';
			            html+='';
			            html+='';
			            html+='</ul>';
			            html+='</div>';
						return html;
					}},
                ],
                "bServerSide": true,
                "sAjaxSource": "/redpacket/redpacketAsAjax",
                "fnServerData": retrieveData,
                "oLanguage": {
                    "sInfoEmpty": "没有数据",
                    "sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
                    "sZeroRecords": "没有检索到数据",
                    "oPaginate": {
                        "sFirst": "首页",
                        "sPrevious": "前页",
                        "sNext": "后页",
                        "sLast": "尾页"
                    }
                },

                "fnDrawCallback": function () {
	                $(".del").click(function(a) {
						$.messager.confirm("", "是否确认删除？", function() { 
					        location.href="/redpacket/delete/"+a.delegateTarget.id.substring(4);
					    });
					});
                },

                "bRetrieve": true,
                "aoColumnDefs": [
                    {
                        sDefaultContent: '',
                        aTargets: [ '_all' ]
                    }
                ]

            })
        })
        $(document).on("scroll", ".dataTables_scrollBody", function () {
            $(".dataTables_scrollBody").css({"overflow": "visible", "height": "100%"})
        })
    });

</script>